/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.max.oti.system.dao.hibernate;

import com.max.oti.system.dao.interfac.IModalityDao;
import com.max.oti.system.dao.util.GenericEntityDao;
import com.max.oti.system.model.Modality;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Hibernate;

/**
 *
 * @author Nigelito
 */
public class ModalityDao extends GenericEntityDao<Modality, Long> implements IModalityDao{

    @Override
    public List listHQL(String hql, int lazyChargeOption) throws Exception {
        List<Modality> list = new ArrayList<Modality>();
        if( lazyChargeOption == 1 ){
            list = getSessionFactory().getCurrentSession()
                .createQuery(hql)
                .list();
            
            for (int i = 0; i < list.size(); i++) {
                for (int j = 0; j < list.get(i).getRequirementList().size(); j++) {
                    Hibernate.initialize(list.get(i).getRequirementList().get(j));
                }
            }
        }
        
        return list;
    }
    
    
    
}
